<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <script src="https://unpkg.com/vue-router@4"></script> 
</head>
<body>
    <body>
    <div id="app">
        <router-link :to="{name: 'home'}">主页</router-link>
        <!--语句1-->
        <router-view name="Menu"></router-view>
        <!--语句2-->
        <router-view></router-view>
        <!--语句3-->
        <router-view name="Footer"></router-view>
    </div>
</body>
<script>
    //局部组件
    const Home = {
        template: '<h2>主页信息</h2>'
    }
    const Menu = {
        template: '<h3>菜单信息</h3>'
    }
    const Footer = {
        template: '<h3>页脚信息</h3>'
    }
    const routes = [
        {
            path: '/',
            name: 'home',
            components: { //语句4
                default: Home,
                Menu: Menu,
                Footer: Footer
            }
        }
    ]
    const router = VueRouter.createRouter({
        history: VueRouter.createWebHashHistory(),
        routes: routes
    })

    //创建Vue应用实例
    const appObj = Vue.createApp({})
    appObj.use(router)
    appObj.mount('#app')
</script>
</body>
</html>